package com.ruoyi.college.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.college.domain.ExperimentReport;
import com.ruoyi.college.service.IExperimentReportService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 实验报告成绩Controller
 * 
 * @author ruoyi
 * @date 2025-09-01
 */
@Controller
@RequestMapping("/college/studentExperimentReport")
public class ExperimentStudentReportController extends BaseController
{
    private String prefix = "college/studentExperimentReport";

    @Autowired
    private IExperimentReportService experimentReportService;

    @RequiresPermissions("college:studentExperimentReport:view")
    @GetMapping()
    public String studentExperimentReport()
    {
        return prefix + "/studentExperimentReport";
    }

    /**
     * 查询实验报告成绩列表
     */
    @RequiresPermissions("college:studentExperimentReport:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ExperimentReport experimentReport)
    {
        startPage();
        List<ExperimentReport> list = experimentReportService.selectExperimentReportList(experimentReport);
        return getDataTable(list);
    }

    /**
     * 导出实验报告成绩列表
     */
    @RequiresPermissions("college:studentExperimentReport:export")
    @Log(title = "实验报告成绩", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ExperimentReport experimentReport)
    {
        List<ExperimentReport> list = experimentReportService.selectExperimentReportList(experimentReport);
        ExcelUtil<ExperimentReport> util = new ExcelUtil<ExperimentReport>(ExperimentReport.class);
        return util.exportExcel(list, "实验报告成绩数据");
    }

    /**
     * 新增实验报告成绩
     */
    @RequiresPermissions("college:studentExperimentReport:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存实验报告成绩
     */
    @RequiresPermissions("college:studentExperimentReport:add")
    @Log(title = "实验报告成绩", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ExperimentReport experimentReport)
    {
        return toAjax(experimentReportService.insertExperimentReport(experimentReport));
    }

    /**
     * 修改实验报告成绩
     */
    @RequiresPermissions("college:studentExperimentReport:edit")
    @GetMapping("/edit/{reportId}")
    public String edit(@PathVariable("reportId") Long reportId, ModelMap mmap)
    {
        ExperimentReport experimentReport = experimentReportService.selectExperimentReportByReportId(reportId);
        mmap.put("experimentReport", experimentReport);
        return prefix + "/edit";
    }

    /**
     * 修改保存实验报告成绩
     */
    @RequiresPermissions("college:studentExperimentReport:edit")
    @Log(title = "实验报告成绩", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ExperimentReport experimentReport)
    {
        return toAjax(experimentReportService.updateExperimentReport(experimentReport));
    }

    /**
     * 删除实验报告成绩
     */
    @RequiresPermissions("college:studentExperimentReport:remove")
    @Log(title = "实验报告成绩", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(experimentReportService.deleteExperimentReportByReportIds(ids));
    }
}
